// FindReplaceDlg.h: interface for the CFindReplaceDlg class.
//
//////////////////////////////////////////////////////////////////////

#if !defined(AFX_FINDREPLACEDLG_H__98B9013B_2922_4A8D_9BE1_1D94296C4460__INCLUDED_)
#define AFX_FINDREPLACEDLG_H__98B9013B_2922_4A8D_9BE1_1D94296C4460__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include "../resource.h"
#include "../SimpleWnd/SimpleWnd.h"

class IFindReplaceHost
{
public:
    virtual void FindReplaceDlgDestroyed() = 0;
    virtual void FindNext(const char* str, bool up=false) = 0;
    virtual void Replace(const char* str0, char* str1, bool up=false) = 0;
    virtual void ReplaceAll(const char* str0, char* str1) = 0;
};

class CFindReplaceDlg : public CDialog
{
public:
	CFindReplaceDlg(IFindReplaceHost* host, bool bReplace=false);
	virtual ~CFindReplaceDlg();

    void SetAsReplaceDlg(bool bReplace=true);
    bool IsReplaceDlg() {return m_bReplaceDlg;};

public:
	BEGIN_MSG_MAP(CFindReplaceDlg)
		MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
		MESSAGE_HANDLER(WM_CHAR, OnChar)
		MESSAGE_HANDLER(WM_DESTROY, OnDestroy)
		MESSAGE_HANDLER(WM_NCDESTROY, OnNcDestroy)
		COMMAND_ID_HANDLER(IDCANCEL, OnCancel)
		COMMAND_ID_HANDLER(IDC_NEXT, OnFindNext)
		COMMAND_ID_HANDLER(IDC_REPLACE, OnReplace)
		COMMAND_ID_HANDLER(IDC_REPLACEALL, OnReplace)
	END_MSG_MAP()

	DIALOG_ID(IDD_FINDREPLACE)

protected:
	LRESULT OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
	LRESULT OnChar(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
	LRESULT OnDestroy(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
	LRESULT OnNcDestroy(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
	LRESULT OnFindNext(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
	LRESULT OnReplace(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
	LRESULT OnCancel(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);

protected:
    bool m_bReplaceDlg;
    IFindReplaceHost* m_host;
};

#endif // !defined(AFX_FINDREPLACEDLG_H__98B9013B_2922_4A8D_9BE1_1D94296C4460__INCLUDED_)
